Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support functional optimisticData #1861

Merged
merged 2 commits into from
Feb 18, 2022
Merged

Conversation

huozhi
Copy link
Member

@huozhi huozhi commented Feb 18, 2022

Resolves #1858

@codesandbox-ci
Copy link

codesandbox-ci bot commented Feb 18, 2022

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 377efaa:

Sandbox Source
SWR-Basic Configuration
SWR-States Configuration
SWR-Infinite Configuration
SWR-SSR Configuration

@huozhi huozhi marked this pull request as ready for review February 18, 2022 18:23
@huozhi huozhi requested a review from shuding as a code owner February 18, 2022 18:23
src/types.ts Outdated Show resolved Hide resolved
@shuding shuding merged commit 1bdec37 into vercel:main Feb 18, 2022
@djfarly
Copy link

djfarly commented Mar 27, 2022

Hej @shuding @huozhi,

looks like this merge was an hour late to make it into 1.2.2.

Any chance to release this? Would be greatly appreciated! ❤️

@huozhi huozhi deleted the fn-opt-data branch March 27, 2022 14:25
shuding added a commit that referenced this pull request Apr 10, 2022
* feat: support functional optimisticData

* Update src/types.ts

Co-authored-by: Shu Ding <g@shud.in>
@shuding
Copy link
Member

shuding commented Apr 11, 2022

It’s included in 1.3.0 🎉

nevilm-lt pushed a commit to nevilm-lt/swr-1 that referenced this pull request Apr 22, 2022
* feat: support functional optimisticData

* Update src/types.ts

Co-authored-by: Shu Ding <g@shud.in>
himanshiLt pushed a commit to himanshiLt/swr that referenced this pull request Jun 10, 2022
* feat: support functional optimisticData

* Update src/types.ts

Co-authored-by: Shu Ding <g@shud.in>
@koba04 koba04 mentioned this pull request Aug 5, 2022
13 tasks
@@ -145,7 +145,7 @@ export type MutatorCallback<Data = any> = (
export type MutatorOptions<Data = any> = {
revalidate?: boolean
populateCache?: boolean | ((result: any, currentData: Data) => Data)
optimisticData?: Data
optimisticData?: Data | ((currentData?: Data) => Data)
Copy link

@veewee veewee Sep 21, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool feature! ;)

Shouldn't this be ((currentData?: Data) => Data|undefined)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support optimisticData as a function
4 participants